<%@ page language="java" import="com.brother.service.*,java.util.*,com.brother.model.*,com.brother.realtime.cache.*" contentType="text/html; charset=utf-8"   pageEncoding="utf-8"%><%
com.brother.model.Customer user = (com.brother.model.Customer)session.getAttribute(com.brother.Constants.LOGIN_SESSTION_NAME);
if(user == null)
	return;
//请求此页面的次数
Integer count = (Integer)session.getAttribute("countAlarm");
int limit = 2;
if(count  == null){
	count = 1;
	session.setAttribute("countAlarm", count);
}else{ // 还没到获取缓存的时间
	count++;
	session.setAttribute("countAlarm", count);
}

TrackerService ts = new TrackerService();
List<Tracker> trackers = new ArrayList();

String uin = request.getParameter("uin");

String[] imes = uin.split(",");

for(String s:imes){
	Tracker t  =ts.getTrackerByFieldName("userTrackerId", s);
	if(t != null){
		trackers.add(t);
	}
}

RealDataService s = new RealDataService();	

List<String> datas = null;
if(count < limit || (count % 30 == 0)){ // 还没到获取缓存的时间
	if(count % 30 == 0)
		session.setAttribute("countAlarm", 1);
	datas = s.getTrackersAlarmData(trackers);
	GeoData geoData = GeoDataOutput.getInstance().getGeoData(session.getId());
	for(Tracker t : trackers){
		geoData.getAlarmData(t.getTrackerid());
	}
}else{ // 到了获取缓存时间
	datas = new ArrayList<String>();
	GeoData geoData = GeoDataOutput.getInstance().getGeoData(session.getId());
	for(Tracker t : trackers){
		String d = geoData.getAlarmData(t.getTrackerid());
		if(d != null){
			datas.add(d);
		}
	}
}

for(int i = 0; i < datas.size(); i++){
	out.println(datas.get(i));
}
%><%
com.brother.database.DataBase.closeThreadConnection();
%>
